package net.sxnic.ugr.user.action;

import net.sxnic.ugr.UgrActionSupport;
import net.sxnic.ugr.user.User;
import net.sxnic.ugr.user.UserManager;

import org.springframework.beans.factory.annotation.Autowired;

/**
 * 
 * Introduction：保存用户信息action类
 * 
 * @author 孙宇飞 create date : 2010-5-16
 */
@SuppressWarnings("serial")
public class SaveUserInfo extends UgrActionSupport {

	private User user;

	@Autowired
	private UserManager userManager;

	public void prepare() throws Exception {

		user = userManager.getUserByUsername(net.sxnic.ugr.context.AppContext
				.getUserName(request));
	}

	public String execute() throws Exception {

		try {

			userManager.update(user);

		} catch (Exception e) {
			e.printStackTrace();
		}
		// 保存成功信息并转向
		this.addActionMessage("保存成功！");

		return SUCCESS;
	}

	/**
	 * @return the user
	 */
	public User getUser() {
		return user;
	}

	/**
	 * @param user
	 *            the user to set
	 */
	public void setUser(User user) {
		this.user = user;
	}

}
